﻿<%@ Page Language="C#" MasterPageFile="~/Manage/admin.Master" AutoEventWireup="true" CodeBehind="ExamConfigEdit.aspx.cs" Inherits="Bino.ExamOnline.Manage.ExamConfigEdit" Title="无标题页" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <table style="width: 600px; height: 73px;border-collapse:collapse; border:1px solid #cccccc;">
        <tr>
            <td style="width: 150px;height:30px;" align="right">
                课程名</td>
            <td style="width: 450px;" align="left">
                <asp:DropDownList ID="ddlSubject" runat="server">
                </asp:DropDownList>
                </td>
        </tr>
        <tr>
            <td style="width: 177px;height:30px;" align="right">
                班级名</td>
            <td style="width: 195px;" align="left">
                <asp:DropDownList ID="ddlClass" runat="server">
                </asp:DropDownList>
                </td>
        </tr>
        <tr>
            <td style="width: 177px;height:30px;" align="right">
            考试时间</td>
            <td style="width: 195px;" align="left">
            <asp:DropDownList ID="ddlYear" runat="server"></asp:DropDownList>年<asp:DropDownList ID="ddlMonth" runat="server"></asp:DropDownList>月<asp:DropDownList ID="ddlDay" runat="server"></asp:DropDownList>日<asp:DropDownList ID="ddlHour" runat="server"></asp:DropDownList>时<asp:DropDownList ID="ddlMinute" runat="server"></asp:DropDownList>分</td>
            
        </tr>
        <tr>
            <td align="right" style="width: 177px;height:30px;">
                考试时长</td>
            <td align="left" style="width: 195px;">
                <asp:TextBox ID="txbMinutes" runat="server" Text="90" Columns="3" MaxLength="3" Rows="3"></asp:TextBox>分钟</td>
        </tr>
        <tr>
            <td align="right" style="width: 177px;height:30px;">
                题目类型<br />
                (选择好题目类型)</td>
            <td align="left" style="width: 195px; height: 20px">
                <table style="border:0px; width:400px;">
                    <tr>
                        <td style="width: 40px; cursor:pointer;" onclick="CheckAll()">全选</td><td style="width:40px;">题号</td><td style="width:70px;">题型</td><td style="width:100px;">数量(1-20)</td><td style="width:150px;">分数(本题总分数)</td>
                    </tr>
                    <tr>
                        <td ><input type="checkbox" id="checkbox1" /></td>
                        <td >1</td>
                        <td >
                            <select id="Select1">
                                <option value="1" selected="selected">判断题</option>
                                <option value="2">单选题</option>
                                <option value="3">多选题</option>
                                <option value="4">填空题</option>
                                <option value="5">问答题</option>
                            </select>
                        </td>
                        <td ><input id="topicNum1" maxlength="3" size="3" /></td>
                        <td><input id="topicFraction1" maxlength="3" size="3" /></td>
                    </tr>
                    <tr>
                        <td ><input type="checkbox" id="checkbox2" /></td>
                        <td>2</td>
                        <td>
                            <select id="Select2">
                                <option value="1" selected="selected">判断题</option>
                                <option value="2">单选题</option>
                                <option value="3">多选题</option>
                                <option value="4">填空题</option>
                                <option value="5">问答题</option>
                            </select>
                        </td>
                        <td><input id="topicNum2" maxlength="3" size="3" /></td>
                        <td><input id="topicFraction2" maxlength="3" size="3" /></td>
                    </tr>
                    <tr>
                        <td><input type="checkbox" id="checkbox3" /></td>
                        <td>3</td>
                        <td>
                            <select id="Select3">
                                <option value="1" selected="selected">判断题</option>
                                <option value="2">单选题</option>
                                <option value="3">多选题</option>
                                <option value="4">填空题</option>
                                <option value="5">问答题</option>
                            </select>
                        </td>
                        <td><input id="topicNum3" maxlength="3" size="3" /></td>
                        <td><input id="topicFraction3" maxlength="3" size="3" /></td>
                    </tr>
                    <tr>
                        <td><input type="checkbox" id="checkbox4" /></td>
                        <td>4</td>
                        <td>
                            <select id="Select4">
                                <option value="1" selected="selected">判断题</option>
                                <option value="2">单选题</option>
                                <option value="3">多选题</option>
                                <option value="4">填空题</option>
                                <option value="5">问答题</option>
                            </select>
                        </td>
                        <td><input id="topicNum4" maxlength="3" size="3" /></td>
                        <td><input id="topicFraction4" maxlength="3" size="3" /></td>
                    </tr>
                    <tr>
                        <td><input type="checkbox" id="checkbox5" /></td>
                        <td>5</td>
                        <td>
                            <select id="Select5">
                                <option value="1" selected="selected">判断题</option>
                                <option value="2">单选题</option>
                                <option value="3">多选题</option>
                                <option value="4">填空题</option>
                                <option value="5">问答题</option>
                            </select>
                        </td>
                        <td><input id="topicNum5" maxlength="3" size="3" /></td>
                        <td><input id="topicFraction5" maxlength="3" size="3" /></td>
                    </tr>
                </table>
                <input id="txbTopicConfig" runat="server" type="hidden" />                
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2" style="height: 50px">
                <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="添加" OnClientClick="return CheckForExam();" /></td>
        </tr>
    </table>
<script language="javascript" type="text/javascript">
function $(id){return document.getElementById(id);}

function CheckForExam()
{
    for(var i=1;i<5;i++)
        for(var j=i+1;j<6;j++)
            if($("checkbox"+i).checked && $("checkbox"+j).checked && $("Select"+i).value == $("Select"+j).value )
            {
                alert("不能出现两次选择同样的题型");
                return false;
            }

    var str = '';
    for(var i=1;i<6;i++)
    {
        if($("checkbox"+i).checked)
        {
            if($("topicNum"+i).value.length<1 && $("topicFraction"+i).value.length<1)
            {
                alert("请给已勾选的题型指定题目数量及分数！");
                return false;
            }
            var regNum = /^\d+$/;
            if (regNum.test($("topicNum"+i).value) && regNum.test($("topicFraction"+i).value))
                str += $("Select"+i).value + "," + $("topicNum"+i).value + "," + $("topicFraction"+i).value + "|";
            else
            {
                alert("题目数量和分数只能为纯数字！");
                return false;
            }
        }
        
    }
    $('<%=txbTopicConfig.ClientID %>').value = str;
    return true;
}
function CheckAll()
{
    for(var i=1;i<6;i++)
        $("checkbox"+i).checked = !$("checkbox"+i).checked;
}
</script>
</asp:Content>
